export getBounds = ->
  win = @sender.getOwnerBrowserWindow()
  r = {height,width} = win.getBounds()

  # hack for : setBounds make BrowserWindows larger every time on Windows · Issue #27651 · electron/electron : https://github.com/electron/electron/issues/27651
  _hack = (name)=>
    v = win[name]
    rv = r[name]
    if v
      if rv > v and (rv - v) < 3
        r[name] = v
        return
    win[name] = rv
    return

  ["height","width"].map _hack
  r

export setBounds = (x,y,width,height)->
  win = @sender.getOwnerBrowserWindow()
  # 不用 setPosition 是因为 https://github.com/electron/electron/issues/9477 browserWindow.setPosition(x,y) changed window size (windows/linux) with non default scaleLevel (125% for example)
  win.setBounds {
    x:Math.round(x)
    y:Math.round(y)
    width
    height
  }
  return
